﻿/*****************************************************************************************************
* Gaia Framework for Adobe Flash ©2007-2009
* Author: Steven Sacks
*
* blog: http://www.stevensacks.net/
* forum: http://www.gaiaflashframework.com/forum/
* wiki: http://www.gaiaflashframework.com/wiki/
* 
* By using the Gaia Framework, you agree to keep the above contact information in the source code.
* 
* Gaia Framework for Adobe Flash is released under the MIT License:
* http://www.opensource.org/licenses/mit-license 
*****************************************************************************************************/

package com.eaglesandcobras.games.scenes
{
	import com.gaiaframework.templates.AbstractPreloader;
	import com.gaiaframework.events.AssetEvent;
	import flash.display.MovieClip;
	import flash.events.Event;
	
	public class Preloader extends AbstractPreloader
	{	
		public var _content:Content;
		
		public function Preloader()
		{
			super();
			this.visible = false;
			addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		}
		
		private function onAddedToStage(event:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			stage.addEventListener(Event.RESIZE, onResize);
			onResize();
		}
		
		override public function transitionIn():void
		{
			transitionInComplete();
		}		
		override public function transitionOut():void
		{
			this.visible = false;
			transitionOutComplete();
		}
		
		private function onResize(event:Event = null):void
		{
			x = stage.stageWidth/2 - width/ 2;
			y = stage.stageHeight/2 - height/ 2;
		}
		
		/*********************************
		CONTENT
		**********************************/
		public function get content():MovieClip {
			return _content;
		}
	}
}
